# Maintainer: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=qt6
pkgname=qt6-qtwayland
pkgver=6.7.2
pkgrel=1
pkgdesc="Provides APIs for Wayland"
url="https://qt.io/"
arch="all"
license="LGPL-2.1-only AND LGPL-3.0-only AND GPL-3.0-only AND Qt-GPL-exception-1.0"
depends_dev="
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	vulkan-headers
	"
makedepends="$depends_dev
	cmake
	perl
	samurai
	"
subpackages="$pkgname-dev"
options="!check" # No tests
builddir="$srcdir/qtwayland-everywhere-src-${pkgver/_/-}"

# Make sure this package is installed when a Qt application is installed and a
# Wayland session is available on the system
install_if="wayland-libs-server qt6-qtbase-x11"

case $pkgver in
	*_alpha*|*_beta*|*_rc*) _rel=development_releases;;
	*) _rel=official_releases;;
esac

source="https://download.qt.io/$_rel/qt/${pkgver%.*}/${pkgver/_/-}/submodules/qtwayland-everywhere-src-${pkgver/_/-}.tar.xz
	0001-qt6-qtwayland-Client-Ensure-that-guessed-popup-parent-has-a-shell-surface.patch
	0002-qt6-qtwayland-client-guard-against-windows-being-on-a-null-screen.patch
	0003-qt6-qtwayland-Client-Improve-thread-safety-determining-window-size-on-the-render-thread.patch
	"

build() {
	export CFLAGS="$CFLAGS -g1 -flto=auto"
	export CXXFLAGS="$CXXFLAGS -g1 -flto=auto"
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
2cd4f45f05ae60bc7f82b94f2e9c217ee4b8322f60381e1b079b90e0687e51cfbeb10b5dd724e1cca7e422b1b101d2b91c0ee47b1a732411cef330fb052c97c2  qtwayland-everywhere-src-6.7.2.tar.xz
a278bb8c0652999b1187620a7ded28c19cffdbdd42834cbb9ab948598c59a827d22d6a59c4cfd8886702b215694d96f14e868286719f49b99031fbfc308216a0  0001-qt6-qtwayland-Client-Ensure-that-guessed-popup-parent-has-a-shell-surface.patch
ad8f8840ddefb932e46e4080430afa5dadb8f801d38b941bcc1af9f7a5512d249d51d5fc42346ef3c5eafd48c0f70018286ba252ec259a826d44a4bec91ceeca  0002-qt6-qtwayland-client-guard-against-windows-being-on-a-null-screen.patch
c109a7a74be3f0314a8caa82f0263f87464a3bc7e4fb00e2657e682422b1e9bad04be3e1888fc3b1a481ce5e61c3eb87a85d8803fcc69c8f4d42cfbdceba3027  0003-qt6-qtwayland-Client-Improve-thread-safety-determining-window-size-on-the-render-thread.patch
"
